<extend name="Common/back" />

<block name="content">

    <div id="content">
        <div class="page-header">
            <div class="container-fluid">
                <div class="pull-right">
                    <a href="{:U('set')}" data-toggle="tooltip" title="新增"
                    class="btn btn-primary"> <i class="fa fa-plus"></i>
                    </a>
                    <button type="button" data-toggle="tooltip" title="删除"
                    class="btn btn-danger" id="button-delete">
                        <i class="fa fa-trash-o"></i>
                    </button>
                </div>
                <h1>属性管理</h1>
                <ul class="breadcrumb">
                    <li>
                        <a href="{:U('Manage/index')}">首页</a>
                    </li>
                    <li>
                        <a href="javascript:;">属性管理</a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <i class="fa fa-list"></i>
                        属性列表
                    </h3>
                </div>
                <div class="panel-body">

                    <div class="well">
                        <form action="{:U('list')}" method="get">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="form-group">
                                        <label class="control-label" for="input-type_id">
                                            类型
                                        </label>
                      <select name="type_id" id="input-type_id" class="form-control">
                          <option value="0">全部</option>
                          <volist name="type_list" id="type">
                              <option value="{$type['type_id']}" <if condition="$type['type_id']
           eq $filter['type_id']">selected</if> >{$type['type_title']}

                              </option>

                          </volist>
                      </select>
                                    </div>

                                </div>

                            </div>
                            <div class="row">
                                <div class="col-sm-12">
                                    <button type="submit" id="button-filter"
                                    class="btn btn-primary pull-right">
                                        <i class="fa fa-search"></i>
                                        筛选
                                    </button>
                                </div>

                            </div>
                        </form>
                    </div>
                    <form action="{:U('multi')}" method="post" enctype="multipart/form-data" id="form-list">
                        <div class="table-responsive">
                            <table class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <td style="width: 1px;" class="text-center">
                                        <input type="checkbox" id="input-all"/>
                                    </td>

                                    <td class="text-left">
  ID
</td>                           <td class="text-left">
  <a href="{:sortU('list', $filter, $sort, 'attribute_title')}"
  class="{:sortClass($sort, 'attribute_title')}">属性</a>
                </td><td class="text-left">
  类型
</td><td class="text-left">
  输入类型
</td>                           <td class="text-left">
  <a href="{:sortU('list', $filter, $sort, 'sort_number')}"
  class="{:sortClass($sort, 'sort_number')}">排序</a>
                </td>

                                    <td class="text-right">管理</td>
                                </tr>
                                </thead>
                                <tbody>
                                <volist name="rows" id="row">
                                <tr>
                                    <td class="text-center">
                                        <input type="checkbox" name="selected[]"
                                        value="{$row['attribute_id']}" />
                                    </td>

                                    <td class="text-left">{$row['attribute_id']}</td>
                                    <td class="text-left">{$row['attribute_title']}</td>
                                    <td class="text-left">{$row['type_id']}</td>
                                    <td class="text-left">{$row['input_type_id']}</td>
                                    <td class="text-left">{$row['sort_number']}</td>

                                    <td class="text-right">
                                        <a href="{:U('set', ['attribute_id'=>$row['attribute_id']])}"
                                        data-toggle="tooltip" title="编辑" class="btn btn-primary">
                                        <i class="fa fa-pencil"></i></a>
                                    </td>
                                </tr>
                                </volist>
                                </tbody>
                            </table>
                        </div>
                    </form>
                    <div class="row">
                        {$page_html}
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>

<block name="appendJs">

    <script>
        // 全选操作
        $(function() {
            $('#input-all').click(function(evt) {
                // 找到其他的checkbox, 让其checked状态, 与当前的all一致.
                $(':checkbox[name="selected[]"]').prop('checked', $(this).prop('checked'));
                // attr使用在字符串属性上, prop使用在布尔值属性上(checked, selected, readonly, disabled), data使用在数据属性(data-attr)
            });
        });
    </script>

    <script>
        // 确认删除
        $(function(){
            $('#button-delete').click(function(evt) {
                // 判断是否有选择的记录
                if( $(':checkbox[name="selected[]"]:checked').size() > 0) {
                    if (confirm('确定删除否')) {
                        $('#form-list').submit();
                    }
                }
            });
        })
    </script>
</block>